package com.springstudy.handlers;


import com.springstudy.processor.TamakoBeanPostProcessor;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/**
 * @author Tamako
 * @since 2025/1/9 14:41
 */
public class TamakoBeanDefinitionParser implements BeanDefinitionParser {
    @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        //注入一个BeanPostProcessor
        RootBeanDefinition beanDefinition = new RootBeanDefinition();
        beanDefinition.setBeanClass(TamakoBeanPostProcessor.class);
        parserContext.getRegistry().registerBeanDefinition("tamakoBeanPostProcessor", beanDefinition);
        return beanDefinition;
    }
}
